var basePath = "http://localhost:8080/AboutMe";
var userTable;

$(function() {
	userTable = $('#userTable').bootstrapTable({
		url : basePath + '/admin/userList',
		idField : 'userId',
		pagination : true,
		pageSize : 10,
		pageNumber : 1,
		contentType: "application/x-www-form-urlencoded",
		method : 'post',
		dataType : 'json',
		sidePagination: "server",
		toolbar : '#toolbar',
		undefinedText : '',
		columns : [ {
			field : 'userName',
			title : '姓名'
		}, {
			field : 'userPassword',
			title : '密码'
		} , {
			field : 'userEmail',
			title : '邮箱'
		}, {
			field : 'userPhone',
			title : '联系方式'
		}]
	});
	userTable.on('click-row.bs.table', function (e, row, $element) {
		var temp = $($element);
		if(temp.hasClass('select')){
			$('.select').removeClass('select');
		}else{
			$('.select').removeClass('select');
			$($element).addClass('select');
		}
	});
});

function getSelectedRow() {
    var index = userTable.find('tr.select').data('index');
    return userTable.bootstrapTable('getData')[index];
}

function edit(){
	alert(getSelectedRow().userName);
}

function del(){
	userTable.bootstrapTable('remove',{field:'userId',values:[26]});
}